package org.example.controller;

import com.alibaba.druid.sql.visitor.functions.Lpad;
import com.alibaba.druid.util.StringUtils;
import io.jsonwebtoken.JwtBuilder;
import io.jsonwebtoken.Jwts;
import io.jsonwebtoken.SignatureAlgorithm;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.example.mapper.DAmountMapper;
import org.example.pojo.DAmount;
import org.example.pojo.DUser;
import org.example.pojo.View.AmountView;
import org.example.pojo.select.DAmountSelect;
import org.example.service.DAmountService;
import org.example.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.*;

@CrossOrigin(origins = "*")
@RestController
@RequestMapping("amount")
@Tag(name = "水电数据API",description = "DAmount Controller")
public class DAmountController {

    @Autowired
    private DAmountService dAmountService;

    @Operation(summary = "获取全部水电信息")
    @PostMapping("/selectAll")
    public Result<Map> selectAll(@RequestBody DAmountSelect dAmountSelect){
        return dAmountService.selectAll(dAmountSelect);
    }

    @Operation(summary = "获取指定房间水电信息")
    @PostMapping("/selectAmountByApartmentId")
    public Result<Map> SelectAmountByApartmentId(@RequestBody DAmountSelect dAmountSelect){
        return dAmountService.SelectAmountByApartmentId(dAmountSelect);
    }

//    @PostMapping("/addAmount")
//    public Result<Map> AddDAmount(@RequestBody DAmount dAmount ){
//        return dAmountService.AddDAmount(dAmount);
//    }

    @Operation(summary = "获取全部查询日期")
    @PostMapping("/selectAmountDate")
    public Result<List<String>> SelectAmountDate(){
        return dAmountService.SelectAmountDate();
    }

//    @PostMapping("/deleteAmountDate")
//    public Result<Map> DeleteAmountDate(@RequestBody DAmount dAmount){
//        return dAmountService.DeleteAmountDate(dAmount);
//    }
//    @PostMapping("/submitAmount")
//    public Result<Map> SubmitAmount(@RequestBody DAmount dAmount){
//        return dAmountService.SubmitAmount(dAmount);
//    }

    @Operation(summary = "下载水电数据Excel")
    @PostMapping("/downloadAmount")
    public Result<Map> DownloadAmount(@RequestBody DAmountSelect dAmountSelect){
        return dAmountService.DownloadAmount(dAmountSelect);
    }

    //定义了authAspect切面类，进行前置身份验证操作
    @Operation(summary = "获取水电数据加密验证请求接口")
    @ApiResponse(responseCode = "200", description = "成功")
    @PostMapping("/getEncryptionAmount")
    public Result<Map> GetEncryptionAmount(@RequestParam(required = false,value="month") String month){
        return dAmountService.GetEncryptionAmount(month);
    }





}
